/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itschapala.dsw2.controlcobros.Bl;

import Enumeraciones.Estado;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import mx.itschapala.dsw2.controlcobros.dao.PagosDaoLocal;
import mx.itschapala.dsw2.controlcobros.modelo.Pagos;

/**
 *
 * @author Maricela
 */
@Stateless
public class PagosBl implements PagosBlLocal {
    @EJB
    private PagosDaoLocal pagosDao;
    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

    @Override
    public Estado registerPayment(Pagos payment) {
        if (pagosDao.findByUser(payment)){
            return Estado.INCOMPLETE;
        }else {
            //payment.setIdUsuario(user);
            payment.setHora(new Date());
            payment.setFecha(new Date());
            pagosDao.create(payment);
            return Estado.COMPLETE;
        } 
        }

    @Override
    public List<Pagos> getAll() {
        return pagosDao.findAll();
    }
    
    }
